我是靠谱客的博主 漂亮小懒虫,这篇文章主要介绍实验:使用D触发器实现PC(程序计数器),现在分享给大家,希望可以做个参考。

一.要求

D触发器结构,用于存储PC(一个周期)

两个输入:clk与rst,分别连接时钟信号与复位信号

两个输出:pc与inst_ce,分别连接指令存储器的addra与ena

二.verilog代码

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2021/06/05 13:33:30
// Design Name: 
// Module Name: pc
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//
//使用D触发器实现PC
module pc(
input wire clk,
input wire rst,
output reg [31:0]pc,
output reg inst_ce
);
reg [31:0] count;
initial count = 0;
always @(posedge clk)begin
if(rst)begin
count<=0;
inst_ce<=0;
end
else begin
count<=count+4;
//自增加4
inst_ce<=1;
pc<=count;
end
end
endmodule

最后

以上就是漂亮小懒虫最近收集整理的关于实验:使用D触发器实现PC(程序计数器)的全部内容,更多相关实验内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部