集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
楼主: fpgaw

至芯科技【夏宇闻教授专栏】与你一起搞定FPGA设计!

[复制链接]
ddd 发表于 2011-10-19 06:11:13 | 显示全部楼层
请问下:assign  {cout,sum}=a+b+cin; 这个怎么解释呀
ddd 发表于 2011-10-19 06:11:40 | 显示全部楼层
4 位全加器和4 位全加器的仿真程序 有什么不同
【例 3.1】4 位全加器
module adder4(cout,sum,ina,inb,cin);
output[3:0] sum;
output cout;
input[3:0] ina,inb;
input cin;
assign {cout,sum}=ina+inb+cin;
endmodule


`timescale 1ns/1ns

`include "adder4.v"

module adder_tp;                     //测试模块的名字

reg[3:0] a,b;                        //测试输入信号定义为 reg型

reg cin;

wire[3:0] sum;                       //测试输出信号定义为wire型

wire cout;

integer i,j;

adder4 adder(sum,cout,a,b,cin);  //调用测试对象

always #5 cin=~cin;                  //设定 cin的取值

initial

begin

a=0;b=0;cin=0;

for(i=1;i<16;i=i+1)

#10   a=i;                           //设定 a的取值

end
  initial

    begin

    for(j=1;j<16;j=j+1)

    #10   b=j;                               //设定b 的取值

    end

    initial                                  //定义结果显示格式

    begin

    $monitor($time,,,"%d + %d + %b={%b,%d}",a,b,cin,cout,sum);

    #160  $finish;

    end

    endmodule

2者有什么区别  为什么在Q2里面不能用
`timescale 1ns/1ns
`include "adder4.v"
求解答  谢谢
ddd 发表于 2011-10-19 06:12:39 | 显示全部楼层
仿真信号生成问题
1111
library ieee;
   use ieee.std_logic_1164.all;
   use ieee.std_logic_unsigned.all;
   entity test_fadder is
   end entity test_fadder;
   architecture arc1 of test_fadder is
   component f_adder  
  port(ain,bin: in std_logic;
       cin: in std_logic;
       sum,cout: out std_logic);
end component;
signal test_a,test_b,test_c: std_logic;
signal test_co,test_s: std_logic;
begin
u0:f_adder port map(ain=>test_a,bin=>test_b,cin=>test_c,
cout=>test_co,sum=>test_s);
process
begin
test_a<='0';
wait for 400 ns;
test_a<='1';
wait for 400 ns;
test_a<='0';
wait for 200 ns;
test_a<='1';
wait for 1000 ns;
test_a<='0';
wait ;
end process;
process
begin
test_b<='0';
wait for 500 ns;
test_b<='1';
wait for 800 ns;
test_b<='0';
wait ;
end process;
process
begin
test_c<='0';
wait for 400 ns;
test_c<='1';
wait for 700 ns;
test_c<='0';
wait for 400 ns;
test_c<='1';
wait for 600 ns;
test_c<='0';
wait;
end process;
end;

我是以程序直接产生的方法生成仿真输入信号的,为什么点击时序仿真的时候说没有输入信号??顶层实体名为f_adder,请高手指教,,
ddd 发表于 2011-10-19 06:13:10 | 显示全部楼层
怎么用VHDL语言实现2进制转换成16进制?
或者调用IEEE.STD_LOGIC.ARITH库中的什么函数可以实现转换,我目标是要将STD_LOGIC_VECTOR类型的数据转换成16进制显示,不知道该怎么做?
请问哪位高手支支招?感激不尽。
ddd 发表于 2011-10-19 06:13:36 | 显示全部楼层
请教一个 检测低电平的程序
现在的这个程序每检测到一个低电平就会给出一个触发信号
希望能只在检测到第一个低电平时给出触发信号
求大侠指导一下
sig_in:输入信号
h2l:低电平触发信号


module detect_module (clk, sig_in, rst, h2l);
                        
input clk;
input sig_in;
input rst;
output h2l;

reg detect1;
reg detect2;

always @ ( posedge clk )
        if ( rst )
                begin
                        detect1 <= 1'b1;
                        detect2 <= 1'b1;
                end
        else
                begin
                        detect1 <= detect2;
                        detect2 <= sig_in;
                        #1 detect2 <= sig_in | detect2;
                end
assign h2l = detect1 & !detect2;
ddd 发表于 2011-10-19 06:14:18 | 显示全部楼层
为啥这程序波形实现不了辨向,求解释啊
本帖最后由 xiasitai 于 2011-10-10 22:43 编辑

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity time4 is
port(a:in std_logic;
     b:in std_logic;
          clk:in std_logic;
          pp: out std_logic;
          np: out std_logic);
end time4;

architecture Behavioral of time4 is
signal prestate,state: std_logic_vector(1 downto 0);
signal snp,spp:std_logic;
begin
process(a,b,clk)
begin
if(clk'event and clk='1')then
state<=a&b;
if state="00" then
case prestate is
when "01"=>prestate<="00";spp<='1';
when "10"=>prestate<="00";snp<='1';
when others=>prestate<="00";spp<='0';snp<='0';
end case;
elsif state="10" then
case prestate is
when "00"=>prestate<="10";spp<='1';
when "11"=>prestate<="10";snp<='1';
when others=>prestate<="10";spp<='0';snp<='0';
end case;
elsif state="11" then
case prestate is
when "10"=>prestate<="11";spp<='1';
when "01"=>prestate<="11";snp<='1';
when others=>prestate<="11";spp<='0';snp<='0';
end case;
else
case prestate is
when "11"=>prestate<="01";spp<='1';
when "00"=>prestate<="01";snp<='1';
when others=>prestate<="01";spp<='0';snp<='0';
end case;
end if;
end if;
end process;
pp<=spp;
np<=snp;
end Behavioral;
ddd 发表于 2011-10-19 06:15:24 | 显示全部楼层
程序错误
大家帮忙看看下面的程序,有错误,帮忙改改,万分感谢
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity mycounter_60 is
    port(clk,clr,en,bcd1wr,bcd10wr:in std_logic;
         din:in std_logic_vector(3 downto 0);
         bcd1: out std_logic_vector(3 downto 0);
         co: out std_logic;
         bcd10: out std_logic_vector(2 downto 0));
end mycounter_60;

architecture art2 of mycounter_60 is
signal bcd1n:std_logic_vector(3 downto 0);
signal bcd10n:std_logic_vector(2 downto 0);
begin
    PROCESS(clk,clr,en,bcd1wr) is
    begin
        if(clr='0') then
            bcd1n<=(others=>'0');
            bcd10n<=(others=>'0');
        elsif(clk'event and clk='1') then
            if(bcd1wr='1' and en='1') then
                bcd1n<=din;
            elsif(en='1') then
                bcd1n<=bcd1n+1;
                if(bcd1n>=9) then
                    bcd1n<="0000";
                end if;
            end if;
        end if;
    end process;
   
    process(bcd10wr,en,bcd1n) is
    begin
        if(bcd10wr='1' and en='1') then
            bcd10n<=din(2 downto 0);
        elsif(bcd1n=9 and en='1') then
            bcd10n<=bcd10n+1;
            if(bcd10n=5) then
                bcd10n<="000";
                co<='1';
            else
                co<='0';
            end if;
        end if;
    end process;
   
    bcd1<=bcd1n;
    bcd10<=bcd10n;
end art2;
ddd 发表于 2011-10-19 06:15:48 | 显示全部楼层
求教关于2块FPGA板子互相通信的问题
要实现一个CO-SIMULATION,用QUARTUS 编辑控制程序到FPGA,然后用使用MATLAB 和 SMASH模拟一个现实操作,FPGA作为控制部分通过RS232负责接收数据运算完毕输出结果到模拟部分。可是按照要求要使用2块FPGA,请问如何实现两块板子的通信,本人初学者,非常感谢。
夏宇闻 该用户已被删除
夏宇闻 发表于 2011-10-19 20:12:29 | 显示全部楼层
回复 108# ddd


     没有时间回答ddd的提问。提问者应该认真读书后有不明白的地方再提问,自己书不读透,随便乱提问,一会儿提verilog的问题,一会儿提VHDL的问题。也不知道您究竟在学哪一种语言。请珍惜自己的时间和回答问题者的时间,还有读帖子人的时间。我明天清晨飞去重庆开会,一周后再见。不能回答大家的问题请原谅。
ccs 发表于 2011-10-23 10:10:58 | 显示全部楼层
我用锁相环倍频50MHz的时钟,到100MHz。用示波器观看结果周期是对的占空比却是80%,但是我设置的时安装默认的50%,这是怎么回事?
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-7-3 01:34 , Processed in 0.075217 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表