在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 10178|回复: 25

各位大侠,怎么用Verilog设计串并转换电路啊

[复制链接]
发表于 2007-12-20 13:31:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
各位大侠,怎么用Verilog设计串并转换电路啊
发表于 2007-12-21 18:12:57 | 显示全部楼层
用移位寄存器
发表于 2007-12-27 15:27:41 | 显示全部楼层
先把课本读完,再来问问题吧。
发表于 2008-5-17 13:09:36 | 显示全部楼层
具体点 啊
发表于 2008-5-18 12:26:15 | 显示全部楼层
串行输入,并行输出
多时钟输入,单时钟输出

[ 本帖最后由 hudie2002 于 2008-5-18 12:28 编辑 ]
发表于 2008-5-19 17:20:03 | 显示全部楼层
/***************************************
简单的例子,仅供参考
***************************************/
`define data_width 32
module example(
              data_out,
              dout_en,
              data_in,
              data_wr,
              clk,
              rst_n
);
//=============================
//ports declaration
//=============================
output[`data_width -1 : 0]      data_out;
output                          dout_en;
input                           data_in;
input                           data_wr;
input                           clk;
input                           rst_n;
//=============================
//parameter declaration
//=============================
parameter UDLY = 1;
//=============================
//signals declaration
//=============================
reg[`data_width -1 : 0]     shift_reg;
reg[`data_width -1 : 0]     shift_cnt;
wire                        shift_done;
wire                        dout_ne;
//=============================
//main code
//=============================
always @ (posedge clk or negedge rst_n)
   begin
      if(!rst_n)
         shift_reg <= {`data_width{1'b0}};
      else if(data_wr)
         shift_reg <= #UDLY {shift_reg[`data_width -2 : 0],data_in};   
   end
   
always @ (posedge clk or negedge rst_n)
   begin
     if(!rst_n)
       shift_cnt <= {`data_width{1'b0}};
     else if(shift_done)
       shift_cnt <= #UDLY {`data_width{1'b0}};
     else if(data_wr)
       shift_cnt <= shift_cnt + 1'b1;
   end               
assign shift_done = (shift_cnt == `data_width);
assign dout_en = shift_done;              
//================================code end=================================
endmodule
发表于 2008-5-19 22:13:10 | 显示全部楼层
you'd better add a define choise for left shift or right shift
发表于 2008-5-20 10:53:35 | 显示全部楼层
data_out呢?
发表于 2008-5-20 22:51:37 | 显示全部楼层
用移位寄存器和选通器就可以实现了。
发表于 2008-5-26 13:22:42 | 显示全部楼层
/***************************************
简单的例子,仅供参考
楼上的说对,写漏了些东西,
改一改哈
***************************************/
`define data_width 32
`define right_shift
module example(
              data_out,
              dout_en,
              data_in,
              data_wr,
              clk,
              rst_n
);
//=============================
//ports declaration
//=============================
output[`data_width -1 : 0]      data_out;
output                          dout_en;
input                           data_in;
input                           data_wr;
input                           clk;
input                           rst_n;
//=============================
//parameter declaration
//=============================
parameter UDLY = 1;
//=============================
//signals declaration
//=============================
reg[`data_width -1 : 0]     shift_reg;
reg[`data_width -1 : 0]     shift_cnt;
wire                        shift_done;
wire                        dout_en;
//=============================
//main code
//=============================
always @ (posedge clk or negedge rst_n)
   begin
      if(!rst_n)
         shift_reg <= {`data_width{1'b0}};
      else if(data_wr)
`ifdef right_shift
         shift_reg <= #UDLY {data_in,shift_reg[`data_width -1 : 1]};   
`else
         shift_reg <= #UDLY {shift_reg[`data_width -2 : 0],data_in};   
`endif
   end
   
always @ (posedge clk or negedge rst_n)
   begin
     if(!rst_n)
       shift_cnt <= {`data_width{1'b0}};
     else if(shift_done)
       shift_cnt <= #UDLY {`data_width{1'b0}};
     else if(data_wr)
       shift_cnt <= shift_cnt + 1'b1;
   end               
assign shift_done = (shift_cnt == `data_width);
assign dout_en = shift_done;   
assign data_out =   shift_reg;        
//================================code end=================================
endmodule
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

X

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-6-30 05:49 , Processed in 0.023989 second(s), 9 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表