Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Java代码到Verilog?_Java_Verilog - Fatal编程技术网

从Java代码到Verilog?

从Java代码到Verilog?,java,verilog,Java,Verilog,我正在尝试编写一个能够生成Verilog代码的小型java程序。 由于我几乎不懂Verilog语言,我在创建一个简单的示例时遇到了问题 假设我们有两个输入a,b,和一个输出c。还有2个国家State1是初始状态,对于特定的条件,转到State2,该条件要求b=1 在本例中,我的输出将有state2&a作为要满足的条件 问题:使用下面的近似设计,根据我的示例,完整的Verilog代码看起来如何 //simplified without inheritance class Input { S

我正在尝试编写一个能够生成
Verilog
代码的小型java程序。 由于我几乎不懂Verilog语言,我在创建一个简单的示例时遇到了问题

假设我们有两个输入
a,b
,和一个输出
c
。还有2个国家
State1
是初始状态,对于特定的条件,转到
State2
,该条件要求
b=1

在本例中,我的输出将有
state2&a
作为要满足的条件

问题:使用下面的近似设计,根据我的示例,完整的
Verilog
代码看起来如何

//simplified without inheritance
class Input {
    String varname;
    new Input(String varname);
}

class Output {
    String varname;
    String condition;
    new Output(String varname, String condition);
}

class State {
    String varname;
    new State(String varname);
}

class Wire {
    String condition;
    Input input;
    Ouput output;
    new Wire(Input input, Output output, String condition);
}

Input input1 = new Input("a");
Input input2 = new Input("b");
State state1 = new State("initial");
State state2 = new State("following");
Wire wire12 = new Wire(state1, state2, "b");
Ouput output1 = new Output(c, "state2 & a");
基于此,verilog代码的外观如何

module BasicFsm(
    input clock,
    input reset,
    input a,
    input b,
    output c
);

always @(posedge clock)
//how to continue here?

下面的内容将是一个很好的开始,我认为可以很容易地从输入规范派生出一个实现

在将类似的东西投入使用之前,您还需要测试生成的代码,有许多免费的模拟器可供使用。还有一些与免费模拟器相关的问题

模块基本原理(
输入时钟,
输入复位,
输入a,
输入b,
输出寄存器c
);
注册州;
电线连接状态;
localparam S_STATE1=1'b0//你能说出首字母吗
localparam S_STATE2=1'b1//你能说出以下几点吗
始终@(posedge时钟或posedge重置)开始
如果(重置)开始
状态
module BasicFsm(
    input      clock,
    input      reset,
    input      a,
    input      b,
    output reg c
);

reg        state;
wire       nexstate;

localparam S_STATE1    = 1'b0; //Could name initial
localparam S_STATE2    = 1'b1; //Could name following

always @(posedge clock or posedge reset) begin
  if(reset) begin
    state <= S_STATE1;
  end
  else begin
    state <= nextstate
  end
end

//Combinatorial nextstate
always @* begin
  case(state) 
    S_STATE1    : 
     if ( b == 1'b1 ) begin
       nextstate = S_STATE2 ; 
     end
     else begin
       nextstate = state ; //Hold state
     end
    S_STATE2    : nextstate = state ; //locked up forever if you get here
    default     : nextstate = S_STATE1;
  endcase
end

//Combinatorial output
always @* begin
  c = (state == S_STATE2) && (a == 1'b1);
end