作者arloha (我要去澳洲玩!!!)
站內Electronics
標題[問題] Altera QuartusII 的 mega function 問題
時間Fri Aug 7 23:51:13 2009
現在在弄FFT的程式....
在pipeline的時候會用到shift register
這部份我想用QuartusII裡面內建mega function的ram-based shift register來實現
=================================以上不是重點================================
現在我想先寫個測試的程式
希望達成的動作是....
計數器0~7時,數字1~8會依序輸入到SHIFT1這個shift register
而當計數器8~15時,變成數字9~16依序輸入到SHIFT2另一個shift register,而這時
SHIFT1開始依序輸出1~8
當計數器16~23時,數字17~24再次依序輸入到SHIFT1,而SHIFT2依序輸出數字9~16
但是我看我輸出的結果發現SHIFT2的輸出都是錯誤的,輸出的數值都是0或1,而不是
像9 10 11 12 13 14....這樣的數值
程式看了很久感覺沒有問題....不知道是哪邊錯了...還是mega function使用方法錯誤?
下面是我的測試程式!
module test(in,rst,clk,out,count,out1,out2,tap1,tap2);
input rst,clk;
input [7:0]in;
output wire [7:0]out;
wire [7:0]in1;
wire [7:0]in2;
output wire [6:0]count;
output wire [7:0]out1;
output wire [7:0]out2;
output [7:0]tap1;
output [7:0]tap2;
counter128 c128(clk, rst,count);
SHIFT S1(clk,in1,out1,tap1);
SHIFT S2(clk,in2,out2,tap2);
demux d1(in,count[3],in1,in2);
assign out=count[3]? out1:out2;
endmodule
module counter128(clk, rst,count);
input clk;
input rst;
output [6:0] count;
wire [6:0] count;
reg [6:0] counter_in;
assign count=counter_in;
always@(posedge clk)
if(rst)
counter_in<=1'b0;
else
counter_in<=counter_in+1'b1;
endmodule
module demux(in,select,y1,y2);
input [7:0]in;
input select;
output wire [7:0]y1;
output wire [7:0]y2;
assign y1=~select∈
assign y2=select∈
endmodule
========================================================================
下面是mega function 的code
// megafunction wizard: %Shift register (RAM-based)%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altshift_taps
// ============================================================
// File Name: SHIFT.v
// Megafunction Name(s):
// altshift_taps
// ============================================================
// ************************************************************
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
//
// 6.0 Build 178 04/27/2006 SJ Full Version
// ************************************************************
//Copyright (C) 1991-2006 Altera Corporation
//Your use of Altera Corporation's design tools, logic functions
//and other software and tools, and its AMPP partner logic
//functions, and any output files any of the foregoing
//(including device programming or simulation files), and any
//associated documentation or information are expressly subject
//to the terms and conditions of the Altera Program License
//Subscription Agreement, Altera MegaCore Function License
//Agreement, or other applicable license agreement, including,
//without limitation, that your use is for the sole purpose of
//programming logic devices manufactured by Altera and sold by
//Altera or its authorized distributors. Please refer to the
//applicable agreement for further details.
// synopsys translate_off
`timescale 1 ps / 1 ps
// synopsys translate_on
module SHIFT (
clock,
shiftin,
shiftout,
taps);
input clock;
input [7:0] shiftin;
output [7:0] shiftout;
output [7:0] taps;
wire [7:0] sub_wire0;
wire [7:0] sub_wire1;
wire [7:0] taps = sub_wire0[7:0];
wire [7:0] shiftout = sub_wire1[7:0];
altshift_taps altshift_taps_component (
.clock (clock),
.shiftin (shiftin),
.taps (sub_wire0),
.shiftout (sub_wire1)
// synopsys translate_off
,
.clken ()
// synopsys translate_on
);
defparam
altshift_taps_component.lpm_hint = "RAM_BLOCK_TYPE=M512",
altshift_taps_component.lpm_type = "altshift_taps",
altshift_taps_component.number_of_taps = 1,
altshift_taps_component.tap_distance = 8,
altshift_taps_component.width = 8;
endmodule
// ============================================================
// CNX file retrieval info
// ============================================================
// Retrieval info: PRIVATE: CLKEN NUMERIC "0"
// Retrieval info: PRIVATE: GROUP_TAPS NUMERIC "0"
// Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Stratix"
// Retrieval info: PRIVATE: NUMBER_OF_TAPS NUMERIC "1"
// Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
// Retrieval info: PRIVATE: TAP_DISTANCE NUMERIC "8"
// Retrieval info: PRIVATE: WIDTH NUMERIC "8"
// Retrieval info: CONSTANT: LPM_HINT STRING "RAM_BLOCK_TYPE=M512"
// Retrieval info: CONSTANT: LPM_TYPE STRING "altshift_taps"
// Retrieval info: CONSTANT: NUMBER_OF_TAPS NUMERIC "1"
// Retrieval info: CONSTANT: TAP_DISTANCE NUMERIC "8"
// Retrieval info: CONSTANT: WIDTH NUMERIC "8"
// Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL clock
// Retrieval info: USED_PORT: shiftin 0 0 8 0 INPUT NODEFVAL shiftin[7..0]
// Retrieval info: USED_PORT: shiftout 0 0 8 0 OUTPUT NODEFVAL shiftout[7..0]
// Retrieval info: USED_PORT: taps 0 0 8 0 OUTPUT NODEFVAL taps[7..0]
// Retrieval info: CONNECT: @shiftin 0 0 8 0 shiftin 0 0 8 0
// Retrieval info: CONNECT: shiftout 0 0 8 0 @shiftout 0 0 8 0
// Retrieval info: CONNECT: taps 0 0 8 0 @taps 0 0 8 0
// Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
// Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT.v TRUE
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT.inc FALSE
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT.cmp FALSE
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT.bsf FALSE
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT_inst.v FALSE
// Retrieval info: GEN_FILE: TYPE_NORMAL SHIFT_bb.v FALSE
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.136.175.108
※ 編輯: arloha 來自: 220.136.175.108 (08/07 23:54)
1F:推 luckyBF:做testbench wave來看吧!!這樣查錯比較快 08/08 00:28
2F:→ arloha:請問testbench waveform 是說用QuartusII拉測試波形嗎? 08/08 10:34
3F:→ arloha:還是說寫testbench......(QuatursII好像沒辦法接受) 08/08 10:35
4F:→ arloha:如果用modelsim的話...megafunction又變成不能用了 08/08 10:36
5F:→ arloha:我現在只用QuartusII拉波形...得到錯誤的結果 08/08 10:37
6F:→ arloha:自己回....應該是demux那邊的問題! 08/08 19:01
7F:推 zxvc:Quartus II可以餵手寫的testbench。那個功能叫NativeLink。 08/08 19:18
8F:→ zxvc:可以參考本板我的一篇關於Quartus II的文章。 08/08 19:19
9F:→ zxvc:不過那篇是先把Quartus II畫出來的波形滙出成Verilog code。 08/08 19:20
10F:→ zxvc:還有也不全然要照那篇文章設定。其實你不須要Quartus II跑完 08/08 19:24
11F:→ zxvc:compliation後再啟動gate-level simulation,因為compliation 08/08 19:24
12F:→ zxvc:的時間有點久。有時你只想作RTL simulation,設定完 08/08 19:25
13F:→ zxvc:NativeLink就可以跑了。詳細的步驟我也忘了,我現在手邊也沒 08/08 19:26
14F:→ zxvc:Quartus II。 08/08 19:27
15F:→ zxvc:如果試不出來,就去找Quartus II說明書來看,搜尋NativeLink 08/08 19:28
16F:→ zxvc:我當初也是看說明書試出來的。 08/08 19:28
17F:→ arloha:謝謝 08/09 11:36