2016-02-25 54 views
0
module CSHM #(parameter data_width=8,order=4) 
(y,in,clk,reset_n); 

wire [data_width-1:0]coeff[0:order-1]; 
output reg signed [2*data_width-1:0]y; 

input clk,reset_n; 
input signed[data_width-1:0]in; 
integer i; 
wire [15:0] product1,product2,product3,product4,product5,product6,product7,product8; 
wire signed[3:0]lsboutputcoeff; 
wire signed[7:4]msboutputcoeff; 
wire signed[2:0]lsbcount,msbcount; 
wire signed[2:0]lsbselect,msbselect; 

wire signed[2*data_width-1:0]muxoutput,shiftoutlsb,shiftoutmsb; 
    wire [3:0] lsbcoeff; 
    wire [7:4] msbcoeff; 
    //reg [7:0] this_coeff; 

wire [2:0]inputshift; 
wire signed[15:0]muxout; 
wire signed[15:0]leftshiftone,leftshifttwo,leftshiftthree; 
wire [15:0]outputshift; 




bankofprecomputers b1(.product1(product1),.product2(product2),.product3(product3),.product4(product4),.product5(product5),.product6(product6),.product7(product7),.product8(product8),.in(in)); 

genvar count; 
generate   
assign coeff[0]= 8'd1; 
assign coeff[1]= 8'd2; 
assign coeff[2]= 8'd3; 
assign coeff[3]= 8'd4; 
for(count = 0; count < order ; count = count+1) 
begin : gen_loop 
    assign lsbcoeff = coeff[count][3:0]; 
     assign msbcoeff = coeff[count][7:4]; 



shifter s1(.lsboutputcoeff(lsboutputcoeff),.msboutputcoeff(msboutputcoeff),.lsbselect(lsbselect),.msbselect(msbselect),.lsbcount(lsbcount),.msbcount(msbcount),.lsbcoeff(lsbcoeff),.msbcoeff(msbcoeff)); 
    end 
endgenerate 
mux8_1msb m1(.muxoutput(muxoutput),.msbselect(msbselect),.product1(product1),.product2(product2),.product3(product3),.product4(product4),.product5(product5),.product6(product6),.product7(product7),.product8(product8)); 

mux8_1LSB m2(.muxoutput(muxoutput),.lsbselect(lsbselect),.product1(product1),.product2(product2),.product3(product3),.product4(product4),.product5(product5),.product6(product6),.product7(product7),.product8(product8));    

inverse_shifter is1(.shiftoutmsb(shiftoutmsb),.muxoutput(muxoutput),.msbcount(msbcount)); 

inverse_shifter_LSB is2 (.shiftoutlsb(shiftoutlsb),.muxoutput(muxoutput),.lsbcount(lsbcount)); 



     [email protected](negedge clk) 
     begin 
     y = shiftoutmsb+shiftoutlsb; 
      end 



endmodule 

當即時試圖合成,即時得到誤差作爲錯誤的Verilog,使用生成語句CSHM篩選編碼

多源在上信號lsbcoeff3股;這個信號是 連接到多個驅動程序。

多信號源單元信號lsbcoeff0;這個信號是 連接到多個驅動程序。

如果我錯在任何地方,請指導我

回答

1

lsbcoeffmsbcoeff跨過靜態展開產生循環共享,因此你有平行分配到這些網。爲了解決這個問題,你需要使網絡在每個循環中都是唯一的。這可以通過兩種不同的方式完成。

  1. 陣列籃網:

    wire signed [2:0] lsbcount [0:order-1]; 
    wire signed [2:0] msbcount [0:order-1] 
    for(count = 0; count < order ; count = count+1) begin : gen_loop 
        assign lsbcoeff[count] = coeff[count][3:0]; 
        assign msbcoeff[count] = coeff[count][7:4]; 
        ... 
    
  2. 通過宣佈他們產生循環內部本地化網:注:這種形式給出,籃網不會被外界的循環範圍的訪問。

    for(count = 0; count < order ; count = count+1) begin : gen_loop 
        wire signed [2:0] lsbcoeff = coeff[count][3:0]; 
        wire signed [2:0] msbcoeff = coeff[count][7:4]; 
        ... 
    end 
    // lsbcoeff and msbcoeff cannot be accessed outside of the loop 
    
+0

即時得到相同的錯誤... :( –

+0

@SugureshKumarArali,更新問題中的代碼我懷疑你得到了完全相同的錯誤信息,如果你做了正確的更改,我看到相同的多驅動程序問題'lsboutputcoeff'和'msboutputcoeff'。提醒一下,生成塊中的循環並行運行,不是程序性的。 – Greg

+0

好吧,但我有4個係數,必須分成LSB和MSB係數,必須更新請引導我,它是一個CSHM過濾器體系結構 –

0

環或多或少像同一行重複n次。

for(count = 0; count < order ; count = count+1) 
begin : gen_loop 
    assign lsbcoeff = coeff[count][3:0]; 
     assign msbcoeff = coeff[count][7:4]; 
.... 

So @Suguresh,你的原代碼有問題。

正如格雷格正確指出,你需要糾正這一點。對於您的代碼,解決方案1看起來更合適。你可以更改代碼併發布更新以重新檢查嗎? (