作者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