| `timescale 1ns / 1ns |
| `define AUTOMATIC_self |
| `define AUTOMATIC_decode |
| `define AUTOMATIC_noise_couple |
| `define AUTOMATIC_resonator |
| `define AUTOMATIC_prng |
| `include "cav_mech_auto.vh" |
|
|
| module cav_mech( |
| input clk, |
| input start_eig, |
| input start_outer, |
| output signed [17:0] mech_x, |
| output signed [17:0] noise_eig_drive, |
| input signed [17:0] eig_drive, |
| |
| output res_clip, |
| `AUTOMATIC_self |
| ); |
| `undef AUTOMATIC_self |
|
|
| `AUTOMATIC_decode |
|
|
| parameter n_mech_modes = 7; |
| parameter n_cycles = n_mech_modes * 2; |
|
|
| |
| wire signed [17:0] environment; |
| (* lb_automatic *) |
| outer_prod noise_couple |
| (.clk(clk), .start(start_outer), .x(environment), .result(noise_eig_drive), |
| `AUTOMATIC_noise_couple |
| ); |
|
|
| |
| (* lb_automatic *) |
| resonator resonator |
| (.clk(clk), .start(start_eig), |
| .drive(eig_drive), |
| .position(mech_x), .clip(res_clip), |
| `AUTOMATIC_resonator |
| ); |
| |
| wire [31:0] rnda, rndb; |
|
|
| (* lb_automatic *) |
| prng prng |
| (.clk(clk), .rnda(rnda), .rndb(rndb), |
| `AUTOMATIC_prng); |
|
|
| |
| |
| |
| |
| |
| reg signed [11:0] noise_accum=0, noise_1=0, noise_out=0; |
| always @(posedge clk) begin |
| noise_accum <= noise_accum + rndb[2:0] - rndb[5:3]; |
| if (start_eig) begin |
| noise_1 <= noise_accum; |
| noise_out <= noise_1-noise_accum; |
| end |
| end |
| assign environment = noise_out; |
|
|
| `undef AUTOMATIC_prng |
| endmodule |
|
|