设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 91|回复: 0
收起左侧

Quartus Verilog HDL/FPGA 实现 74HC299/74LS299 具有三态双向IO的8位左右移位寄存器

[复制链接]
发表于 2024-1-10 20:05:38 | 显示全部楼层 |阅读模式
main.png
  1. module hc299(        //具有三态双向IO的8位左右移位寄存器 VCC:Pin20 GND:Pin10
  2.         input D0,        //左移最低位输入 Pin11
  3.         input D7,        //右移最高位输入 Pin18
  4.         input S0,        //状态控制0 Pin1
  5.         input S1,        //状态控制1 Pin19
  6.         input CLK,        //时钟(上升沿触发) Pin12
  7.         input OE1,        //输出使能1 Pin2
  8.         input OE2,        //输出使能2 Pin3
  9.         input MR,        //异步下降沿将移位寄存器清零(复位) Pin9
  10.         output Q0,        //寄存器最低位(LSB)映射 Pin8
  11.         output Q7,        //寄存器最高位(MSB)映射 Pin17
  12.         inout [7:0] IO                //[8位宽] 双向IO 数据出入口 Pin:16,4,15,5,14,6,13,7
  13. );

  14. reg [7:0] Q = 8'd0;        //8位移位寄存器Q
  15. assign {Q0,Q7} = {Q[0],Q[7]};
  16. assign IO = (OE1 || OE2 || (S0 && S1)) ? 8'bz : Q;
  17. always @(posedge CLK or negedge MR) begin
  18.         if(!MR) begin
  19.                 Q <= 8'd0;
  20.         end else begin
  21.                 case({S1,S0})
  22.                         2'b00:Q <= Q;        //保持
  23.                         2'b01:Q <= {Q[6:0],D0};                //左移
  24.                         2'b10:Q <= {D7,Q[7:1]};                //右移
  25.                         2'b11:Q <= IO;        //输入
  26.                 endcase
  27.         end
  28. end
  29. endmodule

  30. module main(
  31.         input D0,
  32.         input D7,
  33.         input S0,
  34.         input S1,
  35.         input CLK,
  36.         input OE1,
  37.         input OE2,
  38.         input MR,
  39.         output Q0,
  40.         output Q7,
  41.         inout [7:0] IO
  42. );

  43. hc299 U1(
  44.         .D0(D0),
  45.         .D7(D7),
  46.         .S0(S0),
  47.         .S1(S1),
  48.         .CLK(CLK),
  49.         .OE1(OE1),
  50.         .OE2(OE2),
  51.         .MR(MR),
  52.         .Q0(Q0),
  53.         .Q7(Q7),
  54.         .IO(IO)
  55. );

  56. endmodule
复制代码

相关帖子

您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-27 20:58 , Processed in 0.617035 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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