tilk/digitaljs

Sub window should not bind signal listener to the view in parent paper

yuyichao opened this issue · 0 comments

Haven't found/tested a clean solution yet (and I need to run soon...) so report as an issue for now so that I don't forget...

I tested this with the fsm subwindow but I think this would also affect memory subwindow as well.

The symptom is reproducible with the following source code modified from the fsm example.

module fsm(input clk, rst, a, output b);

  logic [1:0] state;
  
  localparam A = 2'b00;
  localparam B = 2'b01;
  localparam C = 2'b10;
  localparam D = 2'b11;

  always_ff @(posedge clk or posedge rst)
    if (rst) state <= B;
    else casex(state)
      A: state <= C;
      B: state <= D;
      C: if (a) state <= D; else state <= B;
      D: state <= A;
    endcase

  always_comb begin
    b = 1'bx;
    case(state)
      A, D: b = 0;
      B: b = 1;
      C: if (a) b = 1; else b = 0;
    endcase
  end

endmodule

module wrapper(input clk, rst, a, output b);
  fsm fsm_1(clk, rst, a, b);
endmodule
  • Synthesize with the optimization on, fsm into circuit element on (and maybe merge more into fsm for clarity).
  • Open the subcircuit window
  • Open the fsm window
  • Now dragging states around would auto resize the fsm window
  • Close the subcircuit window
  • Now dragging states around in the fsm window will now resize it anymore.

The issue is that the position change listener at

this.listenTo(graph, 'change:position', (elem) => {
is registered on the FSMView, which is destroyed when the subcircuit subwindow is closed and automatically disconnects the listener.

The right solution is to somehow bind this on the paper/div or bind to global circuit and manually remove in the close callback. From the look of it, the memory subwindow has the same issue.

Making this change should also have the benefit of making the display editor function more independent of the view and can make it easier for the user to trigger it in other conditions (e.g. restoring view state).