完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
对于我的任务,我必须将计数器连接到寄存器文件。
显然,这不是完整的代码,我只包括组件: 计数器: 图书馆IEEE; 使用IEEE.std_logic_1164.all; 使用IEEE.std_logic_misc.all; 使用IEEE.std_logic_arith.all; 实体柜台是 通用(延迟:时间:= 8 ns); 端口(Clk:在std_logic; Inc:在std_logic; Rst:在std_logic; i:out std_logic_vector(2 downto 0); j:输出std_logic_vector(2 downto 0); k:输出std_logic_vector(2 downto 0)); 结束柜台; 计数器的架构行为是 开始 P:流程(Clk) 变量值:UNSIGNED(8 downto 0):=“000000000”; 开始 if(Clk'event和Clk ='1')然后 if(Rst ='1')然后 值:=“000000000”; elsif(Inc ='1')然后 值:=值+ 1; 万一; 万一; I(2) 注册: 图书馆ieee; 使用ieee.std_logic_1164.ALL; 使用ieee.std_logic_unsigned.ALL; 实体RegFile IS 通用(延迟:时间:= 8 ns); 端口(R_addr1,R_addr2,W_addr:IN std_logic_vector(7 DOWNTO 0); R_en1,R_en2,W_en:IN std_logic; R_data1,R_data2:OUT INTEGER; W_data:IN INTEGER; Clk:IN std_logic); 结束RegFile; RegFile IS的架构行为 RF类型是INTEGER的数组(0到31,0到7); 信号存储:RF:=( ...); --8 x 8矩阵 开始 WriteProcess:Process(Clk) 变量col_w:std_logic_vector(2 DOWNTO 0); 变量row_w:std_logic_vector(4 DOWNTO 0); 开始 row_w:= W_addr(7 downto 3); col_w:= W_addr(2 downto 0); if(Clk'event和Clk ='1')然后 if(W_en ='1')然后 - 写 - 存储(CONV_INTEGER(row_w),CONV_INTEGER(col_w)) 我试图用计数器来驱动我的地址信号(写地址,读地址)。 问题是,计数器仅输出i,j和k,每3位,而地址需要8位输入。 我不允许更改组件的代码,所以我想知道是否有办法将i,j和k组合到端口映射中的地址。 以上来自于谷歌翻译 以下为原文 For my assignment, I have to connect a counter to the register file. Obviously, this is not the full code, I've only included the components: Counter: Library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_misc.all;use IEEE.std_logic_arith.all;Entity Counter is Generic ( Delay: Time := 8 ns ); Port ( Clk : In std_logic; Inc : In std_logic; Rst : In std_logic; i : Out std_logic_vector(2 downto 0); j : Out std_logic_vector(2 downto 0); k : Out std_logic_vector(2 downto 0) );End Counter;Architecture BEHAVIORAL of Counter is Begin P: Process ( Clk ) Variable Value : UNSIGNED( 8 downto 0 ) := "000000000"; Begin if( Clk'event and Clk = '1' ) then if( Rst = '1' ) then Value := "000000000"; elsif( Inc = '1' ) then Value := Value + 1; End if; End if; i(2) <= Value(8) after Delay; i(1) <= Value(7) after Delay; i(0) <= Value(6) after Delay; j(2) <= Value(5) after Delay; j(1) <= Value(4) after Delay; j(0) <= Value(3) after Delay; k(2) <= Value(2) after Delay; k(1) <= Value(1) after Delay; k(0) <= Value(0) after Delay; End Process P;End BEHAVIORAL; Reg: Library ieee;USE ieee.std_logic_1164.ALL;USE ieee.std_logic_unsigned.ALL; Entity RegFile IS Generic ( Delay: Time := 8 ns ); Port (R_addr1,R_addr2,W_addr: IN std_logic_vector(7 DOWNTO 0); R_en1,R_en2, W_en: IN std_logic; R_data1, R_data2: OUT INTEGER; W_data: IN INTEGER; Clk: IN std_logic );End RegFile;Architecture Behavioral OF RegFile IS type RF is array ( 0 to 31, 0 to 7 ) of INTEGER; signal Storage : RF := ( ...); --8 x 8 matricesBegin WriteProcess: Process(Clk) Variable col_w:std_logic_vector(2 DOWNTO 0); Variable row_w:std_logic_vector(4 DOWNTO 0); Begin row_w := W_addr(7 downto 3); col_w := W_addr(2 downto 0); if( Clk'event and Clk = '1' ) then if(W_en = '1') then -- write -- Storage( CONV_INTEGER(row_w), CONV_INTEGER(col_w)) <= W_data after Delay; End if; End if; End Process; ReadProcess: Process(R_en1, R_addr1, R_en2, R_addr2,Storage) Variable col_r1, col_r2:std_logic_vector(2 DOWNTO 0); Variable row_r1, row_r2:std_logic_vector(4 DOWNTO 0); Begin row_r1 := R_addr1(7 downto 3); col_r1 := R_addr1(2 downto 0); row_r2 := R_addr2(7 downto 3); col_r2 := R_addr2(2 downto 0); if(R_en1 = '1') then R_data1 <= Storage( CONV_INTEGER(row_r1), CONV_INTEGER(col_r1) ) after Delay; else R_data1 <= INTEGER'left; End if; if(R_en2 = '1') then R_data2 <= Storage( CONV_INTEGER(row_r2), CONV_INTEGER(col_r2) ) after Delay; else R_data2 <= INTEGER'left; End if; End Process;End Behavioral; I am attempting to use the counter to drive my address signals (write address, read address). Problem is, counter only outputs i, j, and k, each 3 bits, whereas the addresses take 8 bit inputs. I am not allowed to change the codes of the components, so I am wondering if there is a way to combine i, j, and k to the address in the port mapping. |
|
相关推荐
5个回答
|
|
你当然可以组合信号,你需要的术语是“连接”,这里有一个关于它的线索。
但是,您显然无法将9位数据放入8位端口而不会丢失某些数据。 您需要确定处理此问题的适当方法。 在原帖中查看解决方案 以上来自于谷歌翻译 以下为原文 You can certainly combine signals, the term you need is "concatenation" and there's a thread about it here. However, you obviously can't put 9-bit data into an 8-bit port without losing some data. You will need to determine the appropriate way to deal with this. View solution in original post |
|
|
|
你当然可以组合信号,你需要的术语是“连接”,这里有一个关于它的线索。
但是,您显然无法将9位数据放入8位端口而不会丢失某些数据。 您需要确定处理此问题的适当方法。 以上来自于谷歌翻译 以下为原文 You can certainly combine signals, the term you need is "concatenation" and there's a thread about it here. However, you obviously can't put 9-bit data into an 8-bit port without losing some data. You will need to determine the appropriate way to deal with this. |
|
|
|
@baldwin感谢您对自己的任务直截了当
vitorian.com ---我们这样做很有趣。 总是给予赞誉。 如果您的问题得到解答,请接受解决方案。我不会回复个人信息 - 请改用论坛。 以上来自于谷歌翻译 以下为原文 @baldwin Giving you kudos for being straight about your assignment vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered. I will not answer to personal messages - use the forums instead. |
|
|
|
谢谢,这有帮助。
是的,我知道我将丢失一些数据,因为我使用9位数据进行8位输入。 然后跟着这个问题,我怎样才能选择我丢失的数据的哪一部分? 例如,假设我只想丢失i信号的最左边一位。 这样做是否正确: W_Address另外,当我像这样进行连接时,我可以假设信号是从左到右分配的? 假设我是010,J是111,K是001,它们是否会按顺序分配给W_addr作为10111001? 以上来自于谷歌翻译 以下为原文 Thanks, this helps. And yes, I understand that I will be losing some data, as I'm using 9-bit data for an 8-bit input. This question is then followed up, how would I be able to select what part of the data I'm losing? For example, say I only want to lose the left most bit of the i signal. Would it be correct to do: W_Address <= I(1) & I(0) & J & K;Also, when I do concatenation like this, I can assume the signals are assigned from left to right? Say I is 010, J is 111, and K is 001, would these be assigned to W_addr in order as 10111001? |
|
|
|
@baldwin是的两个问题,虽然对于较大的向量,它可能是更整洁的写:
W_Address这意味着,例如,对于一个32位地址,你不是在写“I(31)&amp; I(30)&amp; I(29)&amp; I(28)&amp; I(27).. “。 对于第二个问题,这取决于您如何定义值。 在这种情况下: 变量值:UNSIGNED(8 downto 0):=“000000000”;您已经请求了一个小端数字,这意味着第0位在左边,第8位在右边(即位是876543210) )。 但是,如果你这样定义了...... 变量值:UNSIGNED(0到8):=“000000000”; ...然后请求大端值并且顺序反转。 一直坚持使用little-endian会更容易,在这种情况下,你当前的假设是完全正确的。 以上来自于谷歌翻译 以下为原文 @baldwinYes to both questions, although for larger vectors it might be neater to write: W_Address <= I(1 downto 0) & J & K;This means that for, say, a 32-bit address, you're not writing "I(31) & I(30) & I(29) & I(28) & I(27)..." For the second question, this depends on how you defined the values. In this case: Variable Value : UNSIGNED( 8 downto 0 ) := "000000000";You've requested a little-endian number, which will mean that bit #0 is on the left and bit #8 is on the right (ie the bits are 876543210). However, if you had defined it like this... Variable Value : UNSIGNED( 0 to 8 ) := "000000000";... then that's requesting a big-endian value and the order gets reversed. It'll be much, much easier to just stick with little-endian all the way, in which case your current assumption is exactly correct. |
|
|
|
只有小组成员才能发言,加入小组>>
2384 浏览 7 评论
2800 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2264 浏览 9 评论
3336 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2431 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
757浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
547浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
369浏览 1评论
1965浏览 0评论
684浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 02:13 , Processed in 1.666228 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号