Browse Source

Removed latches except L_in register

master
amit.b 3 years ago
parent
commit
6ead92f3df
1 changed files with 107 additions and 15 deletions
  1. +107
    -15
      sources_1/imports/Downloads/sc_decoder_fsm.sv

+ 107
- 15
sources_1/imports/Downloads/sc_decoder_fsm.sv View File

@@ -1,7 +1,7 @@
`timescale 1ns/1ps

`define BITS 8
module sc_decoder_fsm #(parameter BITS=8, N=11'd32)(
module sc_decoder_fsm #(parameter BITS=8, N=11'd128)(
input clk, rst,
input in_valid,
input signed [N-1:0][BITS-1:0] y,
@@ -47,7 +47,7 @@ endfunction
localparam d = $clog2(N);

// Internal Signals
logic [N-1:0][BITS-1:0] L_in, L_out;
logic [N-1:0][BITS-1:0] L_in = 'b0, L_out;
logic [d :0] temp_index_f,temp_index_g;
logic [N-1:0] v_in, v_out;
logic [11 :0] jL1,jL2,
@@ -63,8 +63,8 @@ reg [N-1:0]v;
logic [4:0] c_state, n_state;

//Auxiliary registers declarations
logic [d:0] depth,depth_reg;
logic [d:0] node,node_reg;
logic [d:0] depth = 'b0,depth_reg;
logic [d:0] node = 'b0,node_reg;
logic [11:0] tmp_L, tmp_L_reg,
tmp_R, tmp_R_reg,
tmp_U, tmp_U_reg;
@@ -139,11 +139,17 @@ always_comb
begin
u = 0;
v = 0;
// depth = 0;
tmp_L = 0; tmp_R = 0; tmp_U = 0;
ena_L = 0; enb_L = 0;
wea_L = 0;
node = node_reg;
depth = depth_reg;
L_in = L_in;
if(in_valid)
case(c_state)
idle:
begin
L_in = 0;
depth = 0; node = 0;
tmp_L = 0; tmp_R = 0; tmp_U = 0;
ena_L = 0; wea_L = 0; enb_L = 0;
@@ -162,23 +168,30 @@ always_comb
ena_L = 1'b1; wea_L = 1'b1;
enb_L = 0; ena_v = 0;
wea_v = 0; enb_v = 0;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
u = u;
v = v;
for(int k = 0; k < N; k++)
L_in[k] = y[k];
// L_in = y;
n_state = wait_L_logic;
end

wait_L_logic:
begin
L_in = L_in;
depth = depth_reg + 1'b1; node = ((2*node_reg) + 1'b1);
ena_L = 0; wea_L = 0;
tmp_L = 0; enb_L = 1'b1;
ena_v = 0; wea_v = 0;
enb_v = 0;
tmp_R = tmp_R;
tmp_U = tmp_U;
u = u;
v = v;
if(depth < d)
@@ -190,7 +203,14 @@ always_comb
wait_L:
begin
u = u;
// depth = depth_reg;
v = v;
L_in = L_in;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
ena_L = ena_L; enb_L = enb_L;
wea_L = wea_L;
// depth = depth_reg;
n_state = state_L;
end

@@ -203,7 +223,9 @@ always_comb
ena_v = 0; wea_v = 0; enb_v = 0;
tmp_L = tmp_L_reg + 1'b1;
tmp_R = tmp_R;
tmp_U = tmp_U;
temp_index_f = ((N/(2**(depth+1'b1))) * ((2*(node) + 1'b1) - ((2**(depth + 1'b1)) - 1'b1)));
jL1 = (tmp_L_reg) + temp_index_f;
@@ -223,8 +245,13 @@ always_comb
begin
u = u;
v = v;
L_in = L_in;
ena_L = ena_L; enb_L = enb_L;
wea_L = wea_L;
depth = depth_reg - 1'b1;
node = node_reg + 1'b1;
tmp_L = tmp_L;
tmp_U = tmp_U;
tmp_R = 0;
n_state = wait_R;
end
@@ -232,10 +259,15 @@ always_comb
wait_R:
begin
// depth = depth_reg;
L_in = L_in;
ena_L = 0;wea_L = 0; enb_L = 1'b1;
ena_v = 0;wea_v = 0; enb_v = 1'b1;
wea_L = wea_L;
u = u;
v = v;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
n_state = state_R;
end
@@ -247,6 +279,8 @@ always_comb
ena_L = 1'b1; wea_L = 1'b1; enb_L = 0;
ena_v = 0; wea_v = 0; enb_v = 0;
tmp_L = tmp_L;
tmp_U = tmp_U;
tmp_R = tmp_R_reg + 1'b1;
temp_index_f = ((N/(2**(depth + 1'b1))) * ((2*(node) + 1'b1) -((2**(depth + 1'b1)) - 1'b1)));
temp_index_g = ((N/(2**(depth + 1'b1))) * ((2*(node - 1'b1) + 1'b1)-((2**(depth + 1'b1)) - 1'b1)));
@@ -271,28 +305,41 @@ always_comb
begin
depth = depth_reg - 1'b1;
node = (node_reg - 2) >> 1;
L_in = L_in;
tmp_U = 0;
wea_L = wea_L;
u = u;
v = v;
ena_L = ena_L; enb_L = enb_L;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
n_state = wait_U;
end
wait_U:
begin
// depth = depth_reg;
L_in = L_in;
ena_L = 0; wea_L = 0; enb_L = 0;
ena_v = 0; wea_v = 0; enb_v = 1'b1;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
n_state = state_U;
end
state_U:
begin
// depth = depth_reg;
L_in = L_in;
ena_L = 0; ena_v =1'b1; enb_L = 0;
wea_L = 0; wea_v =1'b1; enb_v = 0;
u = u;
v = v;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U_reg+1'b1;
temp_index_f = ((N/(2**(depth))) * ((2*node + 1'b1) - ((2**(depth)) - 1'b1)));
@@ -316,7 +363,14 @@ always_comb
begin
u = u;
v = v;
// depth = depth_reg;
L_in = L_in;
wea_L = wea_L;
// depth = depth_reg;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
ena_L = ena_L; enb_L = enb_L;
node = (node_reg - 1'b1) >> 1;
n_state = wait_LRU;
@@ -325,10 +379,14 @@ always_comb
wait_LRU:
begin
// depth = depth_reg;
L_in = L_in;
u = u;
v = v;
ena_L = 0; wea_L = 0; enb_L = 1'b1;
ena_v = 0; wea_v = 0; enb_v = 0;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
n_state = state_LRU;
end
@@ -339,7 +397,11 @@ always_comb
ena_L = 0; ena_v = 1'b1;
enb_v = 0; wea_v = 1'b1;
wea_L = 0; enb_L = 0;
L_in = L_in;
v = v;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
temp_index_f = ((N/(2**(depth))) * ((2*node + 1'b1) - ((2**(depth)) - 1'b1)));
fminsum_calc(L_out[temp_index_f],L_out[temp_index_f + 1],LRU[0]);
@@ -363,8 +425,14 @@ always_comb
begin
u = u;
v = v;
L_in = L_in;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
depth = depth_reg + 1'b1; node = node_reg;
ena_L = ena_L; enb_L = enb_L;
wea_L = wea_L;
n_state = wait_lnode;
end
@@ -373,6 +441,10 @@ always_comb
// depth = depth_reg;
u = u;
v = v;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
L_in = L_in;
ena_L = 0; wea_L = 0; enb_L = 1'b1;
ena_v = 0; wea_v = 0; enb_v = 0;
@@ -384,8 +456,12 @@ always_comb
// depth = depth_reg;
u = u;
v = v;
L_in = L_in;
ena_L = 0; wea_L = 0; enb_L = 0;
ena_v = 1'b1; wea_v = 1'b1; enb_v = 0;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
temp_index_f = ((N/(2**(depth))) * ((2*node + 1'b1) - ((2**(depth)) - 1'b1)));
@@ -407,9 +483,15 @@ always_comb
begin
u = u;
v = v;
L_in = L_in;
// depth = depth_reg;
node = node_reg;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
ena_L = ena_L; enb_L = enb_L;
wea_L = wea_L;
n_state = wait_lstate;
end
@@ -418,18 +500,26 @@ always_comb
// depth = depth_reg;
u = u;
v = v;
L_in = L_in;
ena_L = 0; wea_L = 0; enb_L = 1'b1;
ena_v = 0; wea_v = 0; enb_v = 0;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
n_state = state_last;
end
state_last:
begin
// depth = depth_reg;
L_in = L_in;
u = u;
ena_L = 0; wea_L = 0; enb_L = 0;
ena_v = 1'b1; wea_v = 1'b1; enb_v = 0;
tmp_L = tmp_L;
tmp_R = tmp_R;
tmp_U = tmp_U;
v = v_out;
@@ -439,11 +529,12 @@ always_comb
begin
u = 0;
v = 0;
L_in = 0;
depth = 0; node = 0;
tmp_L = 0; tmp_R = 0; tmp_U = 0;
ena_L = 0; wea_L = 0; enb_L = 0;
ena_L = 0; enb_L = 0; wea_L = 0;
ena_v = 0; wea_v = 0; enb_v = 0;
n_state = idle;
end
endcase
@@ -451,6 +542,7 @@ always_comb
begin
u = 0;
v = 0;
L_in = 0;
depth = 0; node = 0;
tmp_L = 0; tmp_R = 0; tmp_U = 0;
ena_L = 0; wea_L = 0; enb_L = 0;


Loading…
Cancel
Save