#qi-hardware IRC log for Monday, 2017-01-09

wpwrakwhitequark: btw, are misssing letters in the text screen a known issue ? i'm using commit 7dbbd75: 10:02
DocScrutinizer05ooh I thought it's Portuguese. ;-)  Seems mostly "b" is missing, then a "V" and a "F"11:16
wpwrakyeah, it looks almost as if it meant something ;-)11:51
planasbmy blog http://www.embedded.lt .. how to become hw hacker ?13:20
wpwrakwhitequark: in platform/gtkmain.cpp:TextWindowGtk:TextWindowGtk, added  const char *display_tw = getenv("DISPLAY_TW");  set_screen(Gdk::Display::open(display_tw)->get_default_screen());13:34
wpwrakalas, no observable effect :(13:34
wpwrak(that is, unless i put garbage into DISPLAY_TW, which produces "Unable to init server [...]" followed by a segfault. the latter since i don't check the success of Gdk::Display::open)13:36
whitequarkwpwrak: yeah bug #15117:01
whitequarkas for DISPLAY_TW, hmm... not sure17:01
r3duxHi there, would I be able to ask any of you a question about SR-latches or D-latches (i.e. mechanisms for storing state)?17:16
larscwell, you can always ask17:17
r3duxOkay, will do! =D17:17
r3duxI've been reading about SR-latches - and they're quite simply two NOR gates cross-linked which can save state, which is the basis of all memory.17:19
r3duxAfter reading this, I thought "I know, I'll implement this in software to make sure it works and that I understand it." - only, it requires simultaneous outputs from both S (signal) and R (reset) NOR gates.17:20
r3duxAnd I don't know how to do that.17:20
r3duxI don't think I could even synchronise threads to do this.17:21
r3duxOr fake a clock.17:21
r3duxI think it has to be a truly synchronous physical operation.17:22
r3duxBut... I'm merely an inquisitive programmer so I thought I'd ask some higher-powers, which in this case is you.17:22
DocScrutinizer05how about using spice or the like17:23
r3duxI can't get to Dune?17:23
r3duxOr Arakis, if you prefer.17:23
DocScrutinizer05~wiki spice_(computer)17:23
infobotI couldn't find a matching article in wikipedia, look for yerselves: https://en.wikipedia.org/wiki/Special:Search?search=spice_(computer)&go=Go17:23
kyakr3dux: it depends on how you define "simulatenous"17:24
kyakif it means "by the end of sample time", than it can be perfectly done in software17:24
kyakthat's just some logic17:24
kyakfirst calculate Q, than ~Q17:25
DocScrutinizer05I just completely lack the intended purpose of the exercise17:25
r3duxThanks - that's a great suggestion and I'm sure it would work - but I was looking for getting it done without a third-party tool, just in a language17:25
DocScrutinizer05you need to implement a sort of clock, or loop runs17:26
r3duxDocScrutinizer05, the intended purpose is like inception... it's to go down many levels17:26
r3duxkyak, try it.17:27
kyakas you can see, it's just a truth table17:27
kyakcan be done in any language17:27
r3duxAgain, sir - try it.17:28
DocScrutinizer05well, then let me start with: nowadays basically all memory is so called "dynamic RAM" which does not work with RS-flipflops17:28
DocScrutinizer05but basically with storage/buffer capacitors17:28
r3duxSo I'm wasting my time?17:28
kyakdefinitely wasting mine...17:29
DocScrutinizer05no idea. I still don't get it what's the pirpose of writing a computer program that simulates one tiny element of that computer17:29
r3duxlol - but saying that, you can't implement it.17:29
r3duxDocScrutinizer05, to understand the nature of things - that's all.17:30
DocScrutinizer05listen buddy, we can implement that sort of thing in a single bash line. We just don't know why we would do that17:30
r3duxI've been working top-down, I want to see how low it goes. 17:30
r3duxI know you can.17:30
whitequarkI think what r3dux asks for is reasonable17:31
whitequarkit's not obvious how to write a logic simulator that properly simulates feedback loops17:31
whitequarkand I don't like the condescending attitude around here, it is a perfectly valid learning exercise17:31
DocScrutinizer05and my answer was: for any sort of simulation based on discrete numeric algorithms you need a sort of time granularity17:32
DocScrutinizer05aka a clock of sorts17:32
r3duxThe D-latch incorporates the clock.17:32
DocScrutinizer05no, that's another clock17:32
whitequarkthat's a different meaning of "clock"17:32
r3duxlearning.com - also, thanks whitequark 17:33
DocScrutinizer05you calculate all states otf output signals for N+1 from input at N17:33
DocScrutinizer05N->N+1 is your clock, the smallest observable time unit17:34
whitequarkwhat DocScrutinizer05 says. basically, you take a snapshot of the state of every wire, then use it to calculate the next state17:34
whitequarkthen replace the state in one step17:34
r3duxWell that's the point isn't it, S = 0, R = 0, Q = previous state17:34
whitequarkyou can assemble a latch from two NOR gates in this way17:35
whitequarkyou don't have to explicitly model it as a latch17:35
whitequarkyou also don't need any threading for this, it can be done in a single threaded way (and really *only* done in a single threaded way if we're taking a single latch)17:35
DocScrutinizer05Q and Q' are outputs and *also* inputs 17:35
r3duxYes they are.17:36
r3duxwhitequark, I don't see how I can implement this in a single-threaded manner. I've tried: calc q, calc notQ using q, re-calc q ---- it's not it.17:37
DocScrutinizer05there is no "e-calc q" thing17:39
whitequarkr3dux: you'll have to explain your algorithm in more exact terms if you want a specific answer17:40
whitequarkor a guidance as to what you're doing wrong17:40
whitequarkcan you write some pseudocode? or actual code also works, sure17:40
r3duxwhitequark - Let me show you a diagram and my code17:41
DocScrutinizer05your system has 4 inputs: Q, Q', R, S. It has two outputs: Qnew, Qnew'. After you calculated Qnew and Qnew', you print the results, then you move Qnew to Q and Qbew' to Q', and restart17:42
DocScrutinizer05this is one cycle N->N+117:42
DocScrutinizer05please, we all know how an RS flipflop is built17:43
DocScrutinizer05anyway looking at that diagram you instantly see my explanation above started with correct assumptions17:44
r3duxI don't mean to demean you, I was just completing the process of: 1.) This is what I want. 2.) This is what I have.17:45
r3duxI didn't know how an RS flipflop was built until this evening.17:46
whitequarkr3dux: so your problem is actually not the fact that you can't nor stuff not in sequence17:46
whitequarkin fact, your srLatch function is very easy to write and I think you can do so; but it cannot be used with the rest of the code.17:47
r3duxwhitequark, my problem is that my attempts to replicate an RS flipflop in software fail17:47
whitequarklet me elaborate.17:47
whitequarkyou understand that an SR latch is an element with state, right?17:47
planasbr3dux: maybe you try to write true table of srlatch17:47
DocScrutinizer05the 'trick' is to not look at the feedback of Q and Q', and simply strictly calculate "from left to right" until you got the output values right side of Q and Q'. Then you "do the loop" and copy the output states to input (left side) for next iteration17:47
whitequarkthis means that the SR latch at iteration loop=1 must take its initial state from the iteration loop=017:48
whitequarkhowever, every invocation of srLatch runs on completely new data17:48
whitequarkso of course, when s[loop]=r[loop]=0 then the latch simply lacks the information to correctly set its outputs17:49
planasbi want to write software to model logic gates and sell it..17:49
whitequarkplanasb: pretty sure iverilog is cheaper than whatever you can come up with... at $017:50
whitequarkr3dux: so do you have any idea how to fix this?17:50
planasbwhitequark: for iOS platform17:50
r3duxwhitequark, with bodges, yes. -1 bodge for sure...17:50
whitequarkr3dux: that's not a bodge.17:50
whitequarkthat's a fundamental fact of how a latch (any latch, or any flip-flop for that matter) works17:51
planasbr3dux: buy some DDR4 chips17:51
whitequarkyou will have to do that even if you forget about SR latches entirely and just use NOR gates (or whichever you have) in your entire model17:51
r3duxplanasb, not sure I need any more than 16GB tbh...17:54
DocScrutinizer05r3dux: for calculating step[N] you take the input for Q and Q' from Q[N-1] and notQ[N-1]17:54
r3duxDocScrutinizer05, I understand. Thank you for your help.17:55
DocScrutinizer05for "Q[-1]" you define either 0 or 1, as you like. To start with. Of course notQ[-1]=~Q[-1] then17:57
DocScrutinizer05or rather, you should define R[-1]=117:57
DocScrutinizer05that is what real hardware does17:57
r3duxThings get real at low-level.17:58
DocScrutinizer05when you power up the RS-Latch, the Reset input gets a power-on-reset17:58
r3duxWhen I power up my toaster it gets warm. Industrial design is also very cool.18:00
r3dux(would love to know how those machines crack walnuts without there being bits of shell in it also - I can't even do that manually)18:01
r3dux<<< off-topic. It was a pleasure to talk with you, and I've learnt a lot. So thank you.18:02
planasbthanks for pointing icarus verilog18:14
DocScrutinizer05for really help him out of this problem (oscillating? most likely) we had needed to start with propagation delay and then even have a short dive into analog aspects of digital circuits19:24
DocScrutinizer05I guess with POR (s)he's fine off, for a start19:25
wpwrakwhitequark going through the tutorial videos ... tutorial #2 https://www.youtube.com/watch?v=13qKQ9BHXCM  has a lot of repetition. can't one just reuse a sketch for each side ?19:35
DocScrutinizer05also maybe silego GreenPak designer would be sth for r3d2<-ux:  R,S,Q->Q: 1,x,x->0;  0,0,Q->Q;  0,1,x->1.   :-D19:37
DocScrutinizer05with a single 3LUT19:38
wpwrakoh, and regarding sending the text window elsewhere, if i remove  TW->set_transient_for(*GW);  the window briefly opens on the other screen, then closes. if i keep on opening/closing it with Tab, it eventually stays there. seems to be some sort of race.19:40
wpwrakhowever, when moving the mouse cursor over the text window (if TW->set_transient_for was not called, no matter on which screen it is), cause it to fail with  Gdk:ERROR:/build/gtk+3.0-VoKwSM/gtk+3.0-3.20.9/./gdk/gdkwindow.c:6153:gdk_window_set_cursor_internal: assertion failed: (!cursor || gdk_window_get_display (window) == gdk_cursor_get_display (cursor))19:42
DocScrutinizer05or create a !RS latch from just two discrete components: resistor and thyristor ;-)19:42
wpwrakcalled from gdkwin->set_cursor in TextWidget:set_cursor_hand19:42
wpwrakcommenting out that call to set_cursor does seem to avoid the crash19:47
wpwrakso we're getting closer :)19:47
wpwrakalso, once i got the window to become stable, it seems to come up without a fuss on subsequent invocations. not sure if it's solvespace remembering something that contributes to the success (i see that it remembers window positions and such), or if it's the window manager remembering it19:49
whitequarkwpwrak: set_transient_for not working is expected20:59
whitequarkwpwrak: as for gdk::cursor::create...20:59
wpwrakyeah, the latter was the bad surprise :)21:00
whitequarkwpwrak: https://developer.gnome.org/gtkmm/stable/classGdk_1_1Cursor.html#a73311ad0d1f0b409090decce724023e321:00
whitequarkuse this overload21:00
whitequarkjust get the TW screen from it21:00
wpwrakthis bringe me to the issue of what a  Glib::RefPtr<Gtk::Display>  really is, how one gets anything done with it without the compiler complaining, and why on earth gtkmm needs to introduce some pointer concept that isn't just a pointer ...21:08
whitequarkGlib::RefPtr is more or less the same thing as std::shared_ptr if you know what that is21:08
wpwraki.e., i tried to store the result of gdk_display_open so that i could check it for MULL, but even that seems hopeless :(21:08
wpwraknyet :)21:09
whitequarkdefine hopeless21:09
whitequarkGlib::RefPtr<T> can be used in the same way as T*21:09
wpwrakC has beautiful pointers, and they're all very standard :)21:09
whitequarkyou can do x->foo() and you can check if(x != NULL)21:09
whitequarkand they don't do the reference counting for you.21:09
whitequarkthanks, but no.21:09
whitequarkgtk has many awful decisions but this one makes a lot of sense21:10
wpwrakhopeless = none of the syntax variations i tried when using it to get_default_screen seemed acceptable to the compiler21:10
whitequarkyou're using Gdk::Display::get_default_screen() right?21:10
whitequarkcan you show me specific code and the error?21:11
wpwrakturning  Gdk::Display::open(display_tw)->get_default_screen()  into  {whatever} dpy = ... ; ...dpy...gdk_display_get_default_screen...21:11
wpwrakerr, no ...21:11
whitequarkGlib::RefPtr<Gdk::Display> dpy = Gdk::Display::open(display_tw);21:12
wpwrakthat was already a form that didn't work. the one that does work is  Gdk::Display::open(display_tw)->get_default_screen()21:12
whitequarkthis will work21:12
whitequarkalso you can use "auto dpy = Gdk::Display::open(display_tw);" in a pinch but I personally prefer to write it out explicitly in C++21:12
wpwrakkewl. that did the trick. thanks !21:16
wpwraknow errors to open the display are just ignored, not crashed upon :)21:16
Action: DocScrutinizer05 idly wonders how you'd generically catch exceptions in C programs. Except of the very obvious coredump and postmortem debug21:28
whitequarkDocScrutinizer05: not really any nicely portable way21:32
whitequarkPOSIX doesn't even let you return from SIGSEGV!21:32
DocScrutinizer05oooh "portable" - yeah for sure not21:32
DocScrutinizer05man 7 signal21:32
wpwraksetjmp/longjmp is a common approximaition of "exceptions" 21:32
whitequarkI am aware21:32
whitequarkit's not legal according to POSIX to siglongjmp out of a SIGSEGV handler21:33
whitequarkit works on basically every OS out there21:33
whitequarkbut not legal according to POSIX anyway21:33
Action: whitequark shrugs21:33
wpwrakwhitequark: ah, i guess it depends on the definition of "exceptions" :) a segfault pretty much means that you're screwed21:34
DocScrutinizer05"SIGSEGV      11       Core    Invalid memory reference " -- but "The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored." so I assumed the others could get intercepted21:34
whitequarkDocScrutinizer05: you can intercept it21:34
DocScrutinizer05oooh, but not return from handler21:35
whitequarkbut you cannot jump out of it or return from it (according to POSIX but not in practice)21:35
whitequarkin reality this works fairly nicely for "userspace virtual memory" schemes21:35
DocScrutinizer05that's ROTFL21:35
wpwrakwhitequark: now ... i'm trying to pass the display i get in TextWindowGtk to the outside world. for deciding on whether i should TW->set_transient_for but also the for the cursor. alas, i can't seem to find a way to get at that TextWindowGtk object21:35
whitequarkI think some ass-backwards architecture doesn't let you catch a SEGV precisely21:35
whitequarkit miiight have been Alpha?21:35
DocScrutinizer05however you wouldn't need to return, after all you don't want to resume21:36
whitequarklet's say I am managing my own file mappings for some reason21:36
whitequarkthen a SEGV is a perfectly fine thing to catch and return from21:36
DocScrutinizer05what you really want is a proper diagnostic output to STDERR21:36
DocScrutinizer05then coredump21:36
whitequarkthere's backtrace(3)... but not standardized21:37
wpwraki'm not even sure what that that parent class of TextWindow is ... https://github.com/ericjang/glsl-playground/blob/master/glwidget.h ? (but there, the reset() doesn't seem to take arguments)21:37
wpwrakoh, wait ... you're defining that one yourself21:37
whitequarkTW is another of those pointers21:37
whitequarkalthough this one is C++'s std::unique_ptr for a reason I do not recall21:38
whitequarkjust do TW->fn() for whatever you want to call21:38
wpwrakgtkmm really is the height of perversion. gtk was made to have a nice graphic library without all the senseless struggle and bloodshed of c++, and then they brought all that right back in :(21:39
whitequarkno. gtkmm makes gtk barely usable21:39
whitequarkas opposed to just being totally unusable, that is.21:40
wpwraki can call things on TW. but how do i get the TextWindowGtk that's somewhere hidden in there ? and as TextWindowGtk not as some other vaguely related class ?21:40
whitequarkerm, TW.get()21:41
wpwrakyes ! thanks ! :)21:42
pcercueiare there still people with nanonotes?21:43
pcercueiI'd like to know if suspend/resume still works on 4.9 or 4.1021:43
wpwrakwhoa ! fun storm coming21:44
wpwrakhmm. get() is not available in TextWidget::set_cursor_hand ?21:50
wpwraki.e., the "get" i used successfully to get the TextWindowGtk in TW->get()21:53
DocScrutinizer05whitequark: when backtrace fails epically, would it nuke the computer? ;-) or 'even worse' the program could maybe SEGFAULT and COREDUMP ;-P21:58
DocScrutinizer05I'm proolly as fuzzy and ambiguous as usual - what I want to say is: it doesn't matter if the process segfaults right away or segfaults in a segfault handler while trying in vain to backtrace()21:59
DocScrutinizer05worst thing you trade in (aka pay) for using the backtrace(3) is an #ifdef to make the shite compile on platforms that never heard of backtrace()22:10
DocScrutinizer05and prolly there are smarter more nifty ways to deal with that, like "unresoved external symbol" that nevertheless doesn'T stop the process from starting normally and would just cause a segfault^2 when the unresolved function call actually gets called... which is no probkem at all as I explained above. I'm not the wizard to handle linker and whatnot in such a way to make that fly, I'm also sure there are even better methods than 22:13
DocScrutinizer05this crude one I just made up22:13
paul_boddiepcercuei: Great timing! Was just about to test something on the Ben.22:30
paul_boddieI did try a fairly recent kernel when that new guy was setting up his purchase from IDA Systems a month or so ago, perhaps.22:31
paul_boddieNot sure if I ever used suspend/resume on the Ben, though.22:31
paul_boddiewhitequark: I think MIPS has some oddness around exceptions that might prevent recovery from SEGV.22:32
pcercueioh cool22:32
mthpcercuei: does suspend still work on Dingoo A320 with current kernels?22:35
pcercueiit's hard to say. Upstream Linux doesn't support the A32022:35
mthI thought you might have a serial-only build for it22:36
pcercueiI have a 4.10 kernel for the A320, but it uses a lot of non-upstream stuff (new TCU drivers, new pinctrl driver)22:36
pcercueiand those drivers might be the reason why I can't suspend/resume22:37
--- Tue Jan 10 201700:00

Generated by irclog2html.py 2.9.2 by Marius Gedminas - find it at mg.pov.lt!