Beruflich Dokumente
Kultur Dokumente
module NLC_4sec_8th_order_1ch(
input clk,
input GlobalReset,
output srdyo, // ufix1
input srdyi, // ufix1
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/////input data storage
latch//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
ch0_select_section_coefficients_mean_1_porty_r<=ch0_select_section_coefficients_mea
n_1_porty;
ch0_select_section_coefficients_mean_2_porty_r<=ch0_select_section_coefficients_mea
n_2_porty;
ch0_select_section_coefficients_mean_3_porty_r<=ch0_select_section_coefficients_mea
n_3_porty;
ch0_select_section_coefficients_mean_4_porty_r<=ch0_select_section_coefficients_mea
n_4_porty;
ch0_select_section_coefficients_stdev_1_porty_r<=ch0_select_section_coefficients_st
dev_1_porty;
ch0_select_section_coefficients_stdev_2_porty_r<=ch0_select_section_coefficients_st
dev_2_porty;
ch0_select_section_coefficients_stdev_3_porty_r<=ch0_select_section_coefficients_st
dev_3_porty;
ch0_select_section_coefficients_stdev_4_porty_r<=ch0_select_section_coefficients_st
dev_4_porty;
ch0_select_section_coefficients_coeff_1_0_porty_r<=ch0_select_section_coefficients_
coeff_1_0_porty;
ch0_select_section_coefficients_coeff_1_1_porty_r<=ch0_select_section_coefficients_
coeff_1_1_porty;
ch0_select_section_coefficients_coeff_1_2_porty_r<=ch0_select_section_coefficients_
coeff_1_2_porty;
ch0_select_section_coefficients_coeff_1_3_porty_r<=ch0_select_section_coefficients_
coeff_1_3_porty;
ch0_select_section_coefficients_coeff_1_4_porty_r<=ch0_select_section_coefficients_
coeff_1_4_porty;
ch0_select_section_coefficients_coeff_1_5_porty_r<=ch0_select_section_coefficients_
coeff_1_5_porty;
ch0_select_section_coefficients_coeff_1_6_porty_r<=ch0_select_section_coefficients_
coeff_1_6_porty;
ch0_select_section_coefficients_coeff_1_7_porty_r<=ch0_select_section_coefficients_
coeff_1_7_porty;
ch0_select_section_coefficients_coeff_1_8_porty_r<=ch0_select_section_coefficients_
coeff_1_8_porty;
ch0_select_section_coefficients_coeff_2_0_porty_r<=ch0_select_section_coefficients_
coeff_2_0_porty;
ch0_select_section_coefficients_coeff_2_1_porty_r<=ch0_select_section_coefficients_
coeff_2_1_porty;
ch0_select_section_coefficients_coeff_2_2_porty_r<=ch0_select_section_coefficients_
coeff_2_2_porty;
ch0_select_section_coefficients_coeff_2_3_porty_r<=ch0_select_section_coefficients_
coeff_2_3_porty;
ch0_select_section_coefficients_coeff_2_4_porty_r<=ch0_select_section_coefficients_
coeff_2_4_porty;
ch0_select_section_coefficients_coeff_2_5_porty_r<=ch0_select_section_coefficients_
coeff_2_5_porty;
ch0_select_section_coefficients_coeff_2_6_porty_r<=ch0_select_section_coefficients_
coeff_2_6_porty;
ch0_select_section_coefficients_coeff_2_7_porty_r<=ch0_select_section_coefficients_
coeff_2_7_porty;
ch0_select_section_coefficients_coeff_2_8_porty_r<=ch0_select_section_coefficients_
coeff_2_8_porty;
ch0_select_section_coefficients_coeff_3_0_porty_r<=ch0_select_section_coefficients_
coeff_3_0_porty;
ch0_select_section_coefficients_coeff_3_1_porty_r<=ch0_select_section_coefficients_
coeff_3_1_porty;
ch0_select_section_coefficients_coeff_3_2_porty_r<=ch0_select_section_coefficients_
coeff_3_2_porty;
ch0_select_section_coefficients_coeff_3_3_porty_r<=ch0_select_section_coefficients_
coeff_3_3_porty;
ch0_select_section_coefficients_coeff_3_4_porty_r<=ch0_select_section_coefficients_
coeff_3_4_porty;
ch0_select_section_coefficients_coeff_3_5_porty_r<=ch0_select_section_coefficients_
coeff_3_5_porty;
ch0_select_section_coefficients_coeff_3_6_porty_r<=ch0_select_section_coefficients_
coeff_3_6_porty;
ch0_select_section_coefficients_coeff_3_7_porty_r<=ch0_select_section_coefficients_
coeff_3_7_porty;
ch0_select_section_coefficients_coeff_3_8_porty_r<=ch0_select_section_coefficients_
coeff_3_8_porty;
ch0_select_section_coefficients_coeff_4_0_porty_r<=ch0_select_section_coefficients_
coeff_4_0_porty;
ch0_select_section_coefficients_coeff_4_1_porty_r<=ch0_select_section_coefficients_
coeff_4_1_porty;
ch0_select_section_coefficients_coeff_4_2_porty_r<=ch0_select_section_coefficients_
coeff_4_2_porty;
ch0_select_section_coefficients_coeff_4_3_porty_r<=ch0_select_section_coefficients_
coeff_4_3_porty;
ch0_select_section_coefficients_coeff_4_4_porty_r<=ch0_select_section_coefficients_
coeff_4_4_porty;
ch0_select_section_coefficients_coeff_4_5_porty_r<=ch0_select_section_coefficients_
coeff_4_5_porty;
ch0_select_section_coefficients_coeff_4_6_porty_r<=ch0_select_section_coefficients_
coeff_4_6_porty;
ch0_select_section_coefficients_coeff_4_7_porty_r<=ch0_select_section_coefficients_
coeff_4_7_porty;
ch0_select_section_coefficients_coeff_4_8_porty_r<=ch0_select_section_coefficients_
coeff_4_8_porty;
ch0_x_adc_r<=ch0_x_adc; ch0_section_limit_r<=ch0_section_limit;
end
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
initial begin
$monitor("c:%b, \t o_add:%b, \t addo:%d, \t i_mult:%b,\t mullto: %d,o_smctofp:%b,
smctofpo_: %d \t %d,\t %b, \t %d, \t %b",
clk,srdy_o_add,add_o_w,srdy_o_mult,mult_o_w,srdy_o_smctofp,smctofp_o_w,add_i2_r,srd
y_i_add,smctofp_o_w,srdyo);
end
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////PORT REGISTOR
DEFINITIONS////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
wire [31:0] add_o_w; wire [31:0] add_i1_w; reg [31:0] add_i1_r; reg [31:0]
add_i2_r; wire [31:0] add_i2_w;
wire [31:0] add_o_w_0; wire [31:0] add_o_w_1; reg srdy_i_add; wire srdy_o_add; wire
[31:0] coef_o_w; wire [31:0] mean_o_w;
reg [31:0] mult_i_r; wire [31:0] mult_i_w; wire [31:0] mult_o_w_1; wire [31:0]
mult_o_w; reg srdy_i_mult;
wire srdy_o_mult; wire [31:0] std_o_w; wire [31:0] store_w;
reg [31:0] store_r; reg store_en; reg flag;
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////PORT AND REGISTOR
CONNECTIONS////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
assign gclk0=(clk) & (gate0); assign gclk1=(clk) & (gate1); assign gclk2=(clk) &
(gate2); assign gclk3=(clk) & (gate3);
assign RESET=(process_reset) | (GlobalReset) | (sysreset); assign srdyo=srdyo_r;
always @ (posedge gclk0) begin
fptosmc_i_r<=ch0_x_adc_r;
add_i1_r<=add_i1_w;
add_i2_r<=add_i2_w;
end
fp_to_smc_float U03(
.clk(gclk0),
.GlobalReset(RESET),
.y_o_portx(fptosmc_o_w),
.x_i(fptosmc_i_r),
.srdyo_o(srdy_o_fptosmc),
.srdyi_i(srdy_i_fptosmc)
);
MUX_2ch_32bit
MUXADD_i1(.inp1(fptosmc_o_w),.inp2(mult_o_w_1),.out(add_i1_w),.sel(process));
MUX_2ch_32bit
MUXADD_i2(.inp1(mean_o_w),.inp2(coef_o_w),.out(add_i2_w),.sel(process));
MUX_2ch_32bit
MUXMULT_i(.inp1(std_o_w),.inp2(store_r),.out(mult_i_w),.sel(process));
MEANMUX
MEAN1(.ch0_select_section_coefficients_mean_1_porty_r(ch0_select_section_coefficien
ts_mean_1_porty_r),
.ch0_select_section_coefficients_mean_2_porty_r(ch0_select_section_coefficients_mea
n_2_porty_r),
.ch0_select_section_coefficients_mean_3_porty_r(ch0_select_section_coefficients_mea
n_3_porty_r),
.ch0_select_section_coefficients_mean_4_porty_r(ch0_select_section_coefficients_mea
n_4_porty_r),
.sec_sel(sec_0),.mean_o_w(mean_o_w));
STDMUX
STD1(.ch0_select_section_coefficients_stdev_1_porty_r(ch0_select_section_coefficien
ts_stdev_1_porty_r),
.ch0_select_section_coefficients_stdev_2_porty_r(ch0_select_section_coefficients_st
dev_2_porty_r),
.ch0_select_section_coefficients_stdev_3_porty_r(ch0_select_section_coefficients_st
dev_3_porty_r),
.ch0_select_section_coefficients_stdev_4_porty_r(ch0_select_section_coefficients_st
dev_4_porty_r),
.sec_sel(sec_0),.std_o_w(std_o_w));
COEFMUX
COEF1(.ch0_select_section_coefficients_coeff_1_0_porty_r(ch0_select_section_coeffic
ients_coeff_1_0_porty_r),
.
ch0_select_section_coefficients_coeff_1_1_porty_r(ch0_select_section_coefficients_c
oeff_1_1_porty_r),
.
ch0_select_section_coefficients_coeff_1_2_porty_r(ch0_select_section_coefficients_c
oeff_1_2_porty_r),
.
ch0_select_section_coefficients_coeff_1_3_porty_r(ch0_select_section_coefficients_c
oeff_1_3_porty_r),
.
ch0_select_section_coefficients_coeff_1_4_porty_r(ch0_select_section_coefficients_c
oeff_1_4_porty_r),
.
ch0_select_section_coefficients_coeff_1_5_porty_r(ch0_select_section_coefficients_c
oeff_1_5_porty_r),
.
ch0_select_section_coefficients_coeff_1_6_porty_r(ch0_select_section_coefficients_c
oeff_1_6_porty_r),
.
ch0_select_section_coefficients_coeff_1_7_porty_r(ch0_select_section_coefficients_c
oeff_1_7_porty_r),
.
ch0_select_section_coefficients_coeff_1_8_porty_r(ch0_select_section_coefficients_c
oeff_1_8_porty_r),
.
ch0_select_section_coefficients_coeff_2_0_porty_r(ch0_select_section_coefficients_c
oeff_2_0_porty_r),
.
ch0_select_section_coefficients_coeff_2_1_porty_r(ch0_select_section_coefficients_c
oeff_2_1_porty_r),
.
ch0_select_section_coefficients_coeff_2_2_porty_r(ch0_select_section_coefficients_c
oeff_2_2_porty_r),
.
ch0_select_section_coefficients_coeff_2_3_porty_r(ch0_select_section_coefficients_c
oeff_2_3_porty_r),
.
ch0_select_section_coefficients_coeff_2_4_porty_r(ch0_select_section_coefficients_c
oeff_2_4_porty_r),
.
ch0_select_section_coefficients_coeff_2_5_porty_r(ch0_select_section_coefficients_c
oeff_2_5_porty_r),
.
ch0_select_section_coefficients_coeff_2_6_porty_r(ch0_select_section_coefficients_c
oeff_2_6_porty_r),
.
ch0_select_section_coefficients_coeff_2_7_porty_r(ch0_select_section_coefficients_c
oeff_2_7_porty_r),
.
ch0_select_section_coefficients_coeff_2_8_porty_r(ch0_select_section_coefficients_c
oeff_2_8_porty_r),
.
ch0_select_section_coefficients_coeff_3_0_porty_r(ch0_select_section_coefficients_c
oeff_3_0_porty_r),
.
ch0_select_section_coefficients_coeff_3_1_porty_r(ch0_select_section_coefficients_c
oeff_3_1_porty_r),
.
ch0_select_section_coefficients_coeff_3_2_porty_r(ch0_select_section_coefficients_c
oeff_3_2_porty_r),
.
ch0_select_section_coefficients_coeff_3_3_porty_r(ch0_select_section_coefficients_c
oeff_3_3_porty_r),
.
ch0_select_section_coefficients_coeff_3_4_porty_r(ch0_select_section_coefficients_c
oeff_3_4_porty_r),
.
ch0_select_section_coefficients_coeff_3_5_porty_r(ch0_select_section_coefficients_c
oeff_3_5_porty_r),
.
ch0_select_section_coefficients_coeff_3_6_porty_r(ch0_select_section_coefficients_c
oeff_3_6_porty_r),
.
ch0_select_section_coefficients_coeff_3_7_porty_r(ch0_select_section_coefficients_c
oeff_3_7_porty_r),
.
ch0_select_section_coefficients_coeff_3_8_porty_r(ch0_select_section_coefficients_c
oeff_3_8_porty_r),
.
ch0_select_section_coefficients_coeff_4_0_porty_r(ch0_select_section_coefficients_c
oeff_4_0_porty_r),
.
ch0_select_section_coefficients_coeff_4_1_porty_r(ch0_select_section_coefficients_c
oeff_4_1_porty_r),
.
ch0_select_section_coefficients_coeff_4_2_porty_r(ch0_select_section_coefficients_c
oeff_4_2_porty_r),
.
ch0_select_section_coefficients_coeff_4_3_porty_r(ch0_select_section_coefficients_c
oeff_4_3_porty_r),
.
ch0_select_section_coefficients_coeff_4_4_porty_r(ch0_select_section_coefficients_c
oeff_4_4_porty_r),
.
ch0_select_section_coefficients_coeff_4_5_porty_r(ch0_select_section_coefficients_c
oeff_4_5_porty_r),
.
ch0_select_section_coefficients_coeff_4_6_porty_r(ch0_select_section_coefficients_c
oeff_4_6_porty_r),
.
ch0_select_section_coefficients_coeff_4_7_porty_r(ch0_select_section_coefficients_c
oeff_4_7_porty_r),
.
ch0_select_section_coefficients_coeff_4_8_porty_r(ch0_select_section_coefficients_c
oeff_4_8_porty_r),
.sec_sel(sec_0),.coef_sel(coef_sel),.coef_o_w(coef_o_w));
smc_float_adder U00(
.clk(gclk0),
.GlobalReset(RESET),
.x_i_porty(add_i1_r),
.y_i_porty(add_i2_r),
.z_o_portx(add_o_w),
.srdyo_o(srdy_o_add),
.srdyi_i(srdy_i_add)
);
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
reg [31:0] store_w_r; reg [31:0] mult_o_w_1_r; reg [31:0] add_o_w_0_r; reg [31:0]
add_o_w_1_r;
assign store_w=store_w_r; assign mult_o_w_1=mult_o_w_1_r; assign
add_o_w_0=add_o_w_0_r; assign add_o_w_1=add_o_w_1_r;
always @ (*) begin
if (op_en==1'b1)
add_o_w_1_r=add_o_w;
else
add_o_w_0_r=add_o_w;
end
smc_float_multiplier U01(
.clk(gclk1),
.GlobalReset(RESET),
.x_i_porty(mult_i_r),
.y_i_porty(feedback_r),
.z_o_portx(mult_o_w),
.srdyo_o(srdy_o_mult),
.srdyi_i(srdy_i_mult)
);
assign ch0_x_lin=ch0_x_lin_r;
smc_float_to_fp U02(
.clk(gclk2),
.GlobalReset(RESET),
.x_i_porty(smctofp_i_r),
.y_o(smctofp_o_w),
.srdyo_o(srdy_o_smctofp),
.srdyi_i(srdy_i_smctofp)
);
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////FSM
CONTROLLER/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
reg [3:0] state; reg [3:0] next_state;
parameter START=4'b0000;
parameter FPTOSMC=4'b0001;
parameter MEANADD=4'b0010;
parameter STDMULT=4'b0011;
parameter LOAD=4'b0100;
parameter HORN_MULT1=4'b0101;
parameter HORN_ADD=4'b0110;
parameter HORN_MULT2=4'b0111;
parameter SMCTOFP=4'b1000;
parameter OUTPUT=4'b1001;
// reset logic
always @ (*) begin
if (GlobalReset) begin
state=START;
next_state=START;
end
end
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//Memory
element ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
always @ (posedge clk) begin
state<=next_state;
end
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//next state
logic /////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
always @ (*) begin
case (state)
4'b0000: begin
if (srdyi==1'b1) begin
next_state=4'b0001;
gate0=1'b1;
end
end
4'b0001: begin
if (srdy_o_fptosmc==1'b1) begin
next_state=4'b0010;
end
end
4'b0010: begin
if (srdy_o_add==1'b1) begin
next_state=4'b0011;
gate1=1'b1;
gate3=1'b1;
end
end
4'b0011: begin
if (srdy_o_mult==1'b1) begin
next_state=4'b0100; // LOAD
store_en=1'b1;
end
end
4'b0100: begin
if (store_en==1'b0) begin
next_state=4'b0101; // HORN_MUL
end
end
4'b0101: begin
if (srdy_o_mult==1'b1) begin
next_state=4'b0110;
gate3=1'b1;
end
end
4'b0110: begin
if (srdy_o_add==1'b1) begin
if (op_en==1'b1) begin
next_state=4'b1000;
gate2=1'b1;
end
else begin
next_state=4'b0111;
end
end
end
4'b0111: begin
if (srdy_o_mult==1'b1) begin
next_state=4'b0110;
if (coef_sel==4'b1000)
op_en=1'b1;
end
end
4'b1000: begin
if (srdy_o_smctofp==1'b1)
next_state=4'b1001;
end
4'b1001: begin
if (flag==1'b1)
next_state=4'b0000;
end
default: next_state=state;
endcase
end
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//current state and output
logic /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
always @ (state) begin
case (state)
4'b0000: begin
sysreset=1'b1;
end
4'b0001: begin
srdy_i_fptosmc=1'b1;
end
4'b0010: begin
srdy_i_add=1'b1;
end
4'b0011: begin
srdy_i_mult=1'b1;
end
4'b0100: begin
store_en=1'b0;
process_reset=1'b1;
process=1'b1;
gate3=1'b0;
end
4'b0101: begin
srdy_i_mult=1'b1;
end
4'b0110: begin
srdy_i_add=1'b1;
end
4'b0111: begin
srdy_i_mult=1'b1;
coef_sel=coef_sel+1;
end
4'b1000: begin
srdy_i_smctofp=1'b1;
end
4'b1001: begin
srdyo_r=1'b1;
flag=1'b1;
end
endcase
end
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
endmodule
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////////MODULE DEFINITIONS
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
module MEANMUX (
ch0_select_section_coefficients_mean_1_porty_r,ch0_select_section_coefficients_mean
_2_porty_r,
ch0_select_section_coefficients_mean_3_porty_r,ch0_select_section_coefficients_mean
_4_porty_r,
sec_sel,mean_o_w);
module STDMUX (
ch0_select_section_coefficients_stdev_1_porty_r,ch0_select_section_coefficients_std
ev_2_porty_r,
ch0_select_section_coefficients_stdev_3_porty_r,ch0_select_section_coefficients_std
ev_4_porty_r,
sec_sel,std_o_w);
ch0_select_section_coefficients_coeff_2_0_porty_r,
ch0_select_section_coefficients_coeff_2_5_porty_r,
ch0_select_section_coefficients_coeff_2_1_porty_r,
ch0_select_section_coefficients_coeff_2_6_porty_r,
ch0_select_section_coefficients_coeff_2_2_porty_r,
ch0_select_section_coefficients_coeff_2_7_porty_r,
ch0_select_section_coefficients_coeff_2_3_porty_r,
ch0_select_section_coefficients_coeff_2_8_porty_r,
ch0_select_section_coefficients_coeff_2_4_porty_r,
ch0_select_section_coefficients_coeff_3_0_porty_r,
ch0_select_section_coefficients_coeff_3_5_porty_r,
ch0_select_section_coefficients_coeff_3_1_porty_r,
ch0_select_section_coefficients_coeff_3_6_porty_r,
ch0_select_section_coefficients_coeff_3_2_porty_r,
ch0_select_section_coefficients_coeff_3_7_porty_r,
ch0_select_section_coefficients_coeff_3_3_porty_r,
ch0_select_section_coefficients_coeff_3_8_porty_r,
ch0_select_section_coefficients_coeff_3_4_porty_r,
ch0_select_section_coefficients_coeff_4_0_porty_r,
ch0_select_section_coefficients_coeff_4_5_porty_r,
ch0_select_section_coefficients_coeff_4_1_porty_r,
ch0_select_section_coefficients_coeff_4_6_porty_r,
ch0_select_section_coefficients_coeff_4_2_porty_r,
ch0_select_section_coefficients_coeff_4_7_porty_r,
ch0_select_section_coefficients_coeff_4_3_porty_r,
ch0_select_section_coefficients_coeff_4_8_porty_r,
ch0_select_section_coefficients_coeff_4_4_porty_r, sec_sel, coef_sel, coef_o_w);