已回答假定已回答

I can't control the DAC(AD5452) verilog code

asb 在 2017-8-13 詢問的問題
最後回覆由YosenBian於2017-8-14提供

我不知道是哪邊錯導致我無法控制這棵DAC

----------------------------------------------------------------------------------------------------------------------------

 

module DAC (clk1, sw, sclk, sync, sdin); input clk1; input  sw; output reg [0:0] sclk; output reg [0:0] sync; output reg [0:0] sdin; reg [15:0] sdin_reg; reg [7:0] seq; reg [7:0] cnt1; reg [7:0] cnt2; always @ (negedge clk1 or negedge sw) begin if (!sw) begin

   sclk <= 1;

              sync <= 1;

              sdin <= 1;

              sdin_reg [15:0] <= 16'b0010000000000000;

              seq <= 0;

              cnt1 <= 15;

              cnt2 <= 15;

end

else begin

   case (seq)

                 0:begin

                                sync = 0;

                                sdin_reg [15:0] = 16'b0010000000000000;

                                           cnt1 <= 15;

                                           seq = seq + 1;

                            end

                             1:begin

                                sdin = (sdin_reg [15:0] >> cnt1) & 1;

                                           cnt1 = cnt1 - 1;

                                           seq = seq + 1;

                             end

                             2:begin

                                sclk = 0;

                                           seq = seq + 1;

                             end

                             3:begin

                                sclk = 1;

                                           if (cnt1 == 0) begin

                                             

             seq = seq + 1;

         end

         else begin

                                             

             seq = 1;

         end

                             end

                             4:begin

                                 sync = 1;

          seq = 0;

                             end

                           

 

              endcase

end

end

endmodule

結果