⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addsub.v

📁 有关于加法器的vhdl编程
💻 V
字号:

//
// This is the adder-subtractor verilog module.
// this code implements a simple and compact
// adder-subtractor.
//
// Input(s): a, b, subtract
// Output(s): sum

// declare the module
module add_sub(sum, a, b, subtract);

output [7:0]sum;
input [7:0]a;
input [7:0]b;
input subtract;
reg [7:0]sum;

// specify the output to change on a change to any input
always @(a or b or subtract)
begin

// if the input signal 'subtract' is a logic '1' then
// the output should be a subtraction of a-b else it's a+b

  if (subtract == 1'b1)
    sum = a - b;
  else
    sum = a + b;

end

endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -